﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using System.Xml;
using System.Net.Sockets;
using System.Media;
using System.Net.NetworkInformation;
using System.Threading;

namespace IT_Pro
{
    public partial class frmMain : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public frmMain()
        {
            InitializeComponent();
        }
        string sv_host=config("Config.xml","server");
        public void ena_ctrl(object sender, EventArgs e)
        {
           this.btnDangNhap.Enabled = false;
        }

        private void btnDangNhap_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmDangNhap frm = new frmDangNhap();           
            frm.ShowDialog();
            if (frm._uSer.Length > 0)
            {
                BangPhanQuyen(frm._uSer);                
            }
        }
        //******goi bang Phan Quyen;
       public string _taiKhoan,_hoTen;      
       private void BangPhanQuyen(string use)
        {
           // doc bang phan quyen
            navChucNang.Visible = true;
           // doc thong tin tai khoan
            DataTable dt = Class.S_TaiKhoan.ThongtinTaiKhoan(use);
            _taiKhoan = dt.Rows[0]["TaiKhoan"].ToString();
            _hoTen = dt.Rows[0]["HoTen"].ToString();
            Class.DataServices.Manv = dt.Rows[0]["MaNV"].ToString();
            lblFullname.Caption ="Đang sử dụng: "+ _hoTen + "  | Thời gian: "+ DateTime.Now + "   |  Máy chủ: "+config("Config.xml","server");

           //hien thi btndoimatkhau
            btnDoiMatKhau.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;

           // goi chuc nang thong bao
            kiemtradulieucanthongbao();
          this.btnNhacViec.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
          timecheckThongBao.Enabled = true;

        }
            //*****het thuc hien phan quyen;
       private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
       {
           Application.Exit();
       }

       private void btnPhanQuyen_ItemClick(object sender, ItemClickEventArgs e)
       {
           /*
           if (!Class.App.IsFocusForm(typeof(Forms.frmPhanQuyen), this))
           {
           Forms.frmPhanQuyen frm = new Forms.frmPhanQuyen();
           frm.MdiParent = this;
           frm.Show();            
           }
           */
           Forms.frmPopupThongBaoMoi frm = new Forms.frmPopupThongBaoMoi();
          // frm.MdiParent = this;
           frm.Left = this.Width - frm.Width-30;
           frm.Top = this.Height - frm.Height-50;
          // frm.Location = new Point(this.Width -( frm.Width + frm.Width), this.Height - (frm.Height+200));

           frm.Show();

       }
              
       private void meNuHTMT_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
       {
          /*
           if (!e.Node.RootNode.Focused)
           {
               MessageBox.Show("" + e.Node.Id);
           }
           */ 
       }

       private void meNuHTMT_MouseDoubleClick(object sender, MouseEventArgs e)
       {
           if (Class.DataServices.checkSV == 0)
           {
               MessageBox.Show("Máy chủ đang offline. bạn không thể sử dụng chức năng này");
               return;
           }


           if (!meNuHTMT.FocusedNode.RootNode.Focused)
           {
               //MessageBox.Show("" + meNuHTMT.FocusedNode.Id);

               switch (meNuHTMT.FocusedNode.Id)
               {
                   case 1:
                       if (!Class.App.IsFocusForm(typeof(Forms.frmMayViTinh), this))
                       {
                           Forms.frmMayViTinh frm = new Forms.frmMayViTinh();
                           frm.MdiParent = this;
                           frm.Show();
                       }
                       break;
                      
                   case 2:
                       if (!Class.App.IsFocusForm(typeof(Forms.frmMayViTinh_info), this))
                       {
                           Forms.frmMayViTinh_info frm = new Forms.frmMayViTinh_info();
                           frm.MdiParent = this;
                           frm.Show();
                       }
                       break;
                       
                   case 3:
                       if (!Class.App.IsFocusForm(typeof(Forms.frmDanhMucLinhKien), this))
                       {
                           Forms.frmDanhMucLinhKien frm = new Forms.frmDanhMucLinhKien();
                           frm.MdiParent = this;
                           frm.Show();
                       }
                       break;
                   case 4:
                       if (!Class.App.IsFocusForm(typeof(Forms.frmDanhMucLinhKien_Edit), this))
                       {
                           Forms.frmDanhMucLinhKien_Edit frm = new Forms.frmDanhMucLinhKien_Edit();
                           
                           frm.ShowDialog();
                       }
                       break;
                   case 5:
                       if (!Class.App.IsFocusForm(typeof(Forms.frmMTDanhMucLinhKienPhongIT), this))
                       {
                           Forms.frmMTDanhMucLinhKienPhongIT frm = new Forms.frmMTDanhMucLinhKienPhongIT();
                           frm.MdiParent = this;
                           frm.Show();
                       }
                       break;
                   case 8:
                       if (!Class.App.IsFocusForm(typeof(Forms.frmNhaCungCap), this))
                       {
                           Forms.frmNhaCungCap frm = new Forms.frmNhaCungCap();
                           frm.ShowDialog();
                       }
                       break;
                   case 9:
                       if (!Class.App.IsFocusForm(typeof(Forms.frmNhaCungCap_Edit), this))
                       {
                           Forms.frmNhaCungCap_Edit frm = new Forms.frmNhaCungCap_Edit();
                           frm.ShowDialog();
                       }
                       break;
               }

           }
       }

       private void btnDoiMatKhau_ItemClick(object sender, ItemClickEventArgs e)
       {
           if (Class.DataServices.checkSV == 0)
           {
               MessageBox.Show("Máy chủ đang offline. bạn không thể sử dụng chức năng này");
               return;
           }

           frmDoiMatKhau frm = new frmDoiMatKhau(this._taiKhoan);
           //
           //this.AddOwnedForm(frm);
          // frm.Owner = this;
           frm.MdiParent = this;
           frm.Show();
           //frm.ShowDialog();
       }

       

       private void btnThemNhanVien_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
       {
           if (Class.DataServices.checkSV == 0)
           {
               MessageBox.Show("Máy chủ đang offline. bạn không thể sử dụng chức năng này");
               return;
           }

           if (!Class.App.IsFocusForm(typeof(Forms.frmNVThemNhanVien), this))
           {
               Forms.frmNVThemNhanVien frm = new Forms.frmNVThemNhanVien();
               frm.MdiParent = this;
               frm.Show();
           }
       }
             

       private void btnQuanLyNhanVien_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
       {
           if (Class.DataServices.checkSV == 0)
           {
               MessageBox.Show("Máy chủ đang offline. bạn không thể sử dụng chức năng này");
               return;
           }

           if (!Class.App.IsFocusForm(typeof(Forms.frmNVQuanLyNhanVien), this))
           {
               Forms.frmNVQuanLyNhanVien frm = new Forms.frmNVQuanLyNhanVien();
               frm.MdiParent = this;
               frm.Show();
           }
       }

       private void btnQuanLyPhongBan_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
       {
           if (Class.DataServices.checkSV == 0)
           {
               MessageBox.Show("Máy chủ đang offline. bạn không thể sử dụng chức năng này");
               return;
           }

           if (!Class.App.IsFocusForm(typeof(Forms.frmNVQuanLyPhongBan), this))
           {
               Forms.frmNVQuanLyPhongBan frm = new Forms.frmNVQuanLyPhongBan();
               frm.MdiParent = this;
               frm.Show();
           }
       }

       private static string config(string url,string bien)
       {
           string _config = "";
           XmlTextReader xmlReader = new XmlTextReader(url);
           while (xmlReader.Read())
           {
               if (xmlReader.Name == bien)
               {
                   _config = xmlReader.ReadElementString();
               }
           }
           xmlReader.Close();
           return _config;
       }

       private void frmMain_Load(object sender, EventArgs e)
       {
           this.Text = this.Text + " " + config("Config.xml", "company") + " V" + config("Config.xml", "version");
                   
           Class.RegistryWriter rg = new Class.RegistryWriter();
           this.defaultGiaoDien.LookAndFeel.SkinName = rg.valuekey("style");
           string user_sv = rg.valuekey("user");
           if (user_sv == "Blue")
               btnCauHinh_ItemClick(null , null);
           else
               btnDangNhap_ItemClick(null, null);

           timechechSv.Enabled = true;
       }

       private void btnStyle1_ItemClick(object sender, ItemClickEventArgs e)
       {
         //  capnhatstyle(btnStyle1.Caption);
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle1.Caption;          
          
               Class.RegistryWriter rg = new Class.RegistryWriter();
               rg.WriteKey("style", btnStyle1.Caption);
          
          
           //MessageBox.Show(rg.valuekey("style"));
       }

       private void capnhatstyle(string style)
       {
           XmlDocument myXmlDocument = new XmlDocument();
           myXmlDocument.Load("Config.xml");
           XmlNode node;
           node = myXmlDocument.DocumentElement;
           // MessageBox.Show(node.Name);
           foreach (XmlNode nodechild in node.ChildNodes)
           {
               //MessageBox.Show(nodechild.Name);
               if (nodechild.Name == "style")
               {
                   nodechild.InnerText = style;
               }

           }
           myXmlDocument.Save("Config.xml");
        }

       private void btnStyle2_ItemClick(object sender, ItemClickEventArgs e)
       {
         //  capnhatstyle(btnStyle2.Caption);
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle2.Caption;
           
           Class.RegistryWriter rg = new Class.RegistryWriter();
           rg.WriteKey("style", btnStyle2.Caption);
          
       }

       private void btnStyle3_ItemClick(object sender, ItemClickEventArgs e)
       {
           //capnhatstyle(btnStyle3.Caption);
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle3.Caption;
         
               Class.RegistryWriter rg = new Class.RegistryWriter();
               rg.WriteKey("style", btnStyle3.Caption);
          
       }

       private void btnStyle4_ItemClick(object sender, ItemClickEventArgs e)
       {
          // capnhatstyle(btnStyle4.Caption);
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle4.Caption;
           
               Class.RegistryWriter rg = new Class.RegistryWriter();
               rg.WriteKey("style", btnStyle4.Caption);
         
       }

       private void btnStyle5_ItemClick(object sender, ItemClickEventArgs e)
       {
          // capnhatstyle(btnStyle5.Caption);
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle5.Caption;
          
               Class.RegistryWriter rg = new Class.RegistryWriter();
               rg.WriteKey("style", btnStyle5.Caption);
           
       }

       private void btnStyle6_ItemClick(object sender, ItemClickEventArgs e)
       {
          // capnhatstyle(btnStyle6.Caption);
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle6.Caption;
          
           Class.RegistryWriter rg = new Class.RegistryWriter();
           rg.WriteKey("style", btnStyle6.Caption);
          
       }

       private void btnStyle7_ItemClick(object sender, ItemClickEventArgs e)
       {
          // capnhatstyle(btnStyle7.Caption);
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle7.Caption;
          
               Class.RegistryWriter rg = new Class.RegistryWriter();
               rg.WriteKey("style", btnStyle7.Caption);
          
       }

       private void btnStyle8_ItemClick(object sender, ItemClickEventArgs e)
       {
           //capnhatstyle(btnStyle8.Caption);
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle8.Caption;
         
               Class.RegistryWriter rg = new Class.RegistryWriter();
           
               rg.WriteKey("style", btnStyle8.Caption);
              
           
       }

       private void btnCauHinh_ItemClick(object sender, ItemClickEventArgs e)
       {
           frmCauHinh frm = new frmCauHinh();
           frm.ShowDialog();
       }

       private void btnStyle9_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle9.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle9.Caption);
       }

       private void btnStyle10_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle10.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle10.Caption);
       }

       private void btnStyle11_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle11.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle11.Caption);
       }

       private void btnStyle12_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle12.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle12.Caption);
       }

       private void btnStyle13_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle13.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle13.Caption);
       }

       private void btnStyle14_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle14.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle14.Caption);
       }

       private void btnStyle15_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle15.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle15.Caption);
       }

       private void btnStyle16_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle16.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle6.Caption);
       }

       private void btnStyle17_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle17.Caption;
        
           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle17.Caption);
       }

       private void btnStyle18_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle18.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle18.Caption);
       }

       private void btnStyle19_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle19.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle19.Caption);
       }

       private void btnStyle20_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle20.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle20.Caption);
       }

       private void btnStyle21_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle21.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle21.Caption);
       }

       private void btnStyle22_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle22.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle22.Caption);
       }

       private void btnStyle23_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle23.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle23.Caption);
       }

       private void btnStyle24_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle24.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle24.Caption);
       }

       private void btnStyle25_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle25.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle25.Caption);
       }

       private void btnStyle26_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.defaultGiaoDien.LookAndFeel.SkinName = btnStyle26.Caption;

           Class.RegistryWriter rg = new Class.RegistryWriter();

           rg.WriteKey("style", btnStyle26.Caption);
       }

       private void btnTkNhanvien_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
       {
           if (Class.DataServices.checkSV == 0)
           {
               MessageBox.Show("Máy chủ đang offline. bạn không thể sử dụng chức năng này");
               return;
           }

           if (!Class.App.IsFocusForm(typeof(Forms.frmThongKeNhanVien), this))
           {
               Forms.frmThongKeNhanVien frm = new Forms.frmThongKeNhanVien();
               frm.MdiParent = this;
               frm.Show();
           }
       }

       private void timechechSv_Tick(object sender, EventArgs e)
       {
           timechechSv.Enabled = false;
           try
           {
               serverThread = new Thread(new ThreadStart(svCheck));
               serverThread.Start();  
           }
           catch { }
           finally { timechechSv.Enabled = true; }
          
       }
       private Thread serverThread;
       private void svCheck()
       {
           TcpClient TcpScan = new TcpClient();
           try
           {
               TcpScan.Connect(sv_host, 1433);
               this.btnCheckSV.Glyph = global::IT_Pro.Properties.Resources._15;
               btnCheckSV.Caption = "online";
               TcpScan.Close();
               Application.DoEvents();
               Class.DataServices.checkSV = 1;
           }

           catch
           {
               this.btnCheckSV.Glyph = global::IT_Pro.Properties.Resources._16;
               btnCheckSV.Caption = "offline";
               Class.DataServices.checkSV = 0;
           }
       }

       private void btnGhiNhanYeuCau_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
       {
           if (Class.DataServices.checkSV == 0)
           {
               MessageBox.Show("Máy chủ đang offline. bạn không thể sử dụng chức năng này");
               return;
           }

           if (!Class.App.IsFocusForm(typeof(Forms.frmCVGhiNhanYeuCau), this))
           {
               Forms.frmCVGhiNhanYeuCau frm = new Forms.frmCVGhiNhanYeuCau();
               frm.MdiParent = this;
               frm.Show();
           }
       }


       private void kiemtradulieucanthongbao()
       {


           try
           {
               string[] ycmoi = Class.CV_GhiNhanYCSuaChua.KiemTraYCSCMoi();
               string[] lichkt = Class.CV_GhiNhanYeuCau.KiemTraLichThucHien();
               int lengArr = 0;
               if (ycmoi != null)
               {
                   lengArr = ycmoi.Length;
               }

               if (lichkt != null)
               {
                   lengArr += lichkt.Length;
               }
               string[] noidung = new string[lengArr];
               int ii = 0;
               if (lichkt != null)
               {
                   for (int i = 0; i < lichkt.Length; i++)
                   {
                       noidung[ii] = lichkt[i];
                       ii++;
                   }

                 
               }
               if (ycmoi != null)
               {
                   for (int i = 0; i < ycmoi.Length; i++)
                   {
                       noidung[ii] = ycmoi[i];
                       ii++;
                   }
                   
               }

               if (ycmoi == null && lichkt == null)
               {
                   timecheckThongBao.Interval = 10000;

               }
               else
               {
                   Forms.frmPopupThongBaoMoi frm = new Forms.frmPopupThongBaoMoi(noidung);
                   frm.Show();
                   timecheckThongBao.Interval = 60000;
               }
           }
           catch { }
       }

       private void timecheckThongBao_Tick(object sender, EventArgs e)
       {
           if (Class.DataServices.checkSV == 1)
           {
               kiemtradulieucanthongbao();
           }
          
       }

       private void btnNhacViec_CheckedChanged(object sender, ItemClickEventArgs e)
       {
           if (btnNhacViec.Checked)
           {
               timecheckThongBao.Enabled = false;
           }
           else
           {
               timecheckThongBao.Enabled = true;
           }
       }

       private void btnCapNhatTongDai_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
       {
           if (Class.DataServices.checkSV == 0)
           {
               MessageBox.Show("Máy chủ đang offline. bạn không thể sử dụng chức năng này");
               return;
           }


           if (!Class.App.IsFocusForm(typeof(Forms.frmCVKichHoatTongDai), this))
           {
               if (Class.DataServices.checkSV == 0)
               {
                   MessageBox.Show("Máy chủ đang offline. bạn không thể sử dụng chức năng này");
                   return;
               }

               Forms.frmCVKichHoatTongDai frm = new Forms.frmCVKichHoatTongDai();
               frm.ShowDialog();
           }
       }

       private void MenuItemThoat_Click(object sender, EventArgs e)
       {
           this.Close();
       }

       private void MenuItemShow_Click(object sender, EventArgs e)

       {
           WindowState = FormWindowState.Maximized;
           this.Show();
       }

       private void btnHideProgam_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.Hide();
           string[] thongbao = new string[] { "Phần mềm đang chạy ẩn trên khay hệ thống !" };

           Forms.frmPopupThongBaoMoi frm = new Forms.frmPopupThongBaoMoi(thongbao);
           frm.Show();
       }

       private void MenuItemStop_Click(object sender, EventArgs e)
       {
           btnNhacViec.Checked = true;
           btnNhacViec_CheckedChanged(null, null);
       }

       private void notifyIcon_DoubleClick(object sender, EventArgs e)
       {
           MenuItemShow_Click(null, null);
       }

       private void mnuThoat_ItemClick(object sender, ItemClickEventArgs e)
       {
           this.Close();
       }

       private void btnmedia1_ItemClick(object sender, ItemClickEventArgs e)
       {
           Class.RegistryWriter rg = new Class.RegistryWriter();
           rg.WriteKey("media", "default_ring.wav");
           Class.DataServices.media = "default_ring.wav";
           SoundPlayer simpleSound = new SoundPlayer(@"media/" + Class.DataServices.media);
           simpleSound.Play();
       }

       private void btnmedia2_ItemClick(object sender, ItemClickEventArgs e)
       {
           Class.RegistryWriter rg = new Class.RegistryWriter();
           rg.WriteKey("media", "buzz.wav");
           Class.DataServices.media = "buzz.wav";
           SoundPlayer simpleSound = new SoundPlayer(@"media/" + Class.DataServices.media);
           simpleSound.Play();
       }

       private void btnmedia3_ItemClick(object sender, ItemClickEventArgs e)
       {
           Class.RegistryWriter rg = new Class.RegistryWriter();
           rg.WriteKey("media", "Yahoo_ring_03.wav");
           Class.DataServices.media = "Yahoo_ring_03.wav";
           SoundPlayer simpleSound = new SoundPlayer(@"media/" + Class.DataServices.media);
           simpleSound.Play();
       }

       private void btnmedia4_ItemClick(object sender, ItemClickEventArgs e)
       {
            Class.RegistryWriter rg = new Class.RegistryWriter();
            rg.WriteKey("media", "yodel.wav");
            Class.DataServices.media = "yodel.wav";
            SoundPlayer simpleSound = new SoundPlayer(@"media/" + Class.DataServices.media);
            simpleSound.Play();
       }

       private void btnLogChinhSach_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
       {
           if (Class.DataServices.checkSV == 0)
           {
               MessageBox.Show("Máy chủ đang offline. bạn không thể sử dụng chức năng này");
               return;
           }

           if (!Class.App.IsFocusForm(typeof(Forms.frmLogChinhSach), this))
           {
               Forms.frmLogChinhSach frm = new Forms.frmLogChinhSach();
               frm.MdiParent = this;
               frm.Show();
           }
       }
          


    }
}